package o;

import android.text.TextUtils;
import com.huawei.appmarket.framework.startevents.control.TabIconCache;
import java.io.File;
import org.json.JSONException;
import org.json.JSONObject;

public class dik {
    public static void ˏ(int i, int i2) {
        new eui("tabIcon_V1_" + String.valueOf(i2)).ˊ("tabIconCount", i);
    }

    public static void ॱ(String str) {
        if (str != null && !dnw.ˊ(new File(str))) {
            Logger.e("TabIconCacheManager", "delete image file error," + str);
        }
    }

    public static void ˊ(TabIconCache tabIconCache, int i, int i2) {
        if (tabIconCache != null) {
            String str = null;
            try {
                str = tabIconCache.toJson();
            } catch (IllegalAccessException e) {
                Logger.e("TabIconCacheManager", "cacheTabIcon error: " + e.toString());
            }
            new eui("tabIcon_V1_" + String.valueOf(i2)).ˋ("tab_icon_info_key" + i, str);
        }
    }

    public static TabIconCache ॱ(int i, int i2) {
        Object ॱ = new eui("tabIcon_V1_" + String.valueOf(i)).ॱ("tab_icon_info_key" + i2, "");
        if (TextUtils.isEmpty(ॱ)) {
            return null;
        }
        TabIconCache tabIconCache = new TabIconCache();
        try {
            tabIconCache.fromJson(new JSONObject(ॱ));
        } catch (IllegalAccessException e) {
            Logger.e("TabIconCacheManager", "getTabIconCache error: " + e.toString());
            tabIconCache = null;
        } catch (InstantiationException e2) {
            Logger.e("TabIconCacheManager", "getTabIconCache error: " + e2.toString());
            tabIconCache = null;
        } catch (ClassNotFoundException e3) {
            Logger.e("TabIconCacheManager", "getTabIconCache error: " + e3.toString());
            tabIconCache = null;
        } catch (JSONException e4) {
            Logger.e("TabIconCacheManager", "getTabIconCache error: " + e4.toString());
            tabIconCache = null;
        }
        return tabIconCache;
    }

    public static void ˏ(int i) {
        ॱ(ˋ(i));
        new eui("tabIcon_V1_" + String.valueOf(i)).ˏˏ();
    }

    public static String ˋ(int i) {
        String str = ContentManager.getInstant().getFilePath() + "/TabIcon/" + String.valueOf(i) + File.separator;
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        File file = new File(str);
        if (file.exists() || file.mkdirs()) {
            return str;
        }
        return null;
    }
}
